<template>
  <view class="login-wrapper flex-col flex-center-y">
    
    <view>
    	<image src="../../static/images/staffIcon.png"
    	style="height: 120rpx;width: 120rpx;margin-top:10rpx;border-radius: 16rpx;"/>
    </view>
    <view class="btn-auth flex-center xztv-row" @click="staff" >
			
      员工入口
    </view>
		
		<view>
			<image src="../../static/images/userIcon.png"
			style="height: 120rpx;width: 120rpx;margin-top:80rpx;border-radius: 16rpx"/>
		</view>
    <view class="btn-auth flex-center">
      业主入口
    </view>
    
		<view class="mt-50 fs-28 zaozao-flex-center" 
		 style="position: fixed;bottom: 40rpx;left:0;right: 0;width: 750rpx;text-align: center;">
			由杭州木耀科技提供服务
		</view>
  </view>
</template>
<script>
import {mpStaffAutoLogin} from '@/api/connect.js'
import storage from "@/utils/storage.js";
export default {
  name: "Login",
 
  
  data: function () {
    return {
     
    };
  },
  watch: {
    
  },
  mounted () { 
    let that = this;
    //获取code
    // uni.login({
    // 	success: (res) => {
    		
    // 		that.login(res.code);
    // 	},
    // });
  },
  onLoad() {
   
  },
  methods: {
    async login(code){
    	let res = await mpStaffAutoLogin({
    		auth_code:code
    	});
    	if(res.data.code==0){
        this.type=res.data.data.type
        this.openid=res.data.data.openid;
        if(this.type=="login"){
          storage.setStaffAccessToken(res.data.data.accessToken);
          uni.redirectTo({
          	url:`/pages/admin/stranger/index`
          })
        }
    	}
    },	
    staff(){
      uni.requestSubscribeMessage({
        
        tmplIds: ['6s2cLvGshWcEUmneVHT1MmEHLfoxyTBjn_q3XOk9REY'],
        success: (resu) => {
          console.log("resu",resu);
          uni.setStorageSync('acceptStoreSubscribeMessage', resu);
          uni.navigateTo({
          	url:`/pages/admin/stranger/index`
          })
        },
        fail: (err) => {
          console.log('订阅失败', err);
        },
      });
      
    }
     
  },
};
</script>
<style lang="scss" scoped>
.code {
  padding:18rpx;
}

.btn-auth {
	width: 498rpx;
	height: 94rpx;
	background: #4274e8;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	font-weight: 400;
	font-size: 28rpx;
	color: #FFFFFF;
	margin-top: 40rpx;
	margin-bottom: 80rpx;
}
.login-popup-box {
	width: 750rpx;
	background: #FFFFFF;
	border-radius: 50rpx 50rpx 0rpx 0rpx;
	position: relative;
	padding-bottom: 100rpx;
}


.acea-row.row-middle {
  input {
    margin-left: 20rpx;
    display: block;
  }
}

.login-wrapper {
  padding: 30rpx;
  background-size: 100% auto !important;
  width: 100vw;
  height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
 
}
</style>
